package cn.com.anypay.manager.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import cn.com.anypay.manager.dto.config.payment.AlipayAppConfig;
import cn.com.anypay.manager.dto.config.payment.AlipayMerchantConfig;

/**
 * 支付宝配置类
 */
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {

    /**
     * 支付宝网关地址
     */
    public static final String GATEWAY_URL = "https://openapi.alipay.com/gateway.do";

    /**
     * 支付宝沙盒网关地址
     */
    public static final String GATEWAY_URL_SANDBOX = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    /**
     * 支付宝正式授权地址
     */
    public static final String OAUTH_URL = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm";

    /**
     * 支付宝沙盒授权地址
     */
    public static final String OAUTH_URL_SANDBOX = "https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm";

    /**
     * 商户应用
     */
    private AlipayAppConfig mchApp;

    /**
     * 普通商户配置
     */
    private AlipayMerchantConfig merchant;

    /**
     * 服务商三方应用配置
     */
    private AlipayAppConfig isvApp;

    /**
     * 特约商户配置
     */
    private AlipayMerchantConfig subMerchant;

    @Bean("alipayAppConfig")
    public AlipayAppConfig appConfig() {
        return mchApp;
    }

    @Bean("alipayMerchantConfig")
    public AlipayMerchantConfig merchantConfig() {
        return merchant;
    }

    @Bean("alipaySubMerchantConfig")
    public AlipayMerchantConfig subMerchantConfig() {
        return subMerchant;
    }

    @Bean("alipayIsvAppConfig")
    public AlipayAppConfig isvAppConfig() {
        return isvApp;
    }

    public AlipayAppConfig getIsvApp() {
        return isvApp;
    }

    public void setIsvApp(AlipayAppConfig isvApp) {
        this.isvApp = isvApp;
    }

    public AlipayAppConfig getMchApp() {
        return mchApp;
    }

    public void setMchApp(AlipayAppConfig app) {
        this.mchApp = app;
    }

    public AlipayMerchantConfig getMerchant() {
        return merchant;
    }

    public void setMerchant(AlipayMerchantConfig merchant) {
        this.merchant = merchant;
    }

    public AlipayMerchantConfig getSubMerchant() {
        return subMerchant;
    }

    public void setSubMerchant(AlipayMerchantConfig subMerchant) {
        this.subMerchant = subMerchant;
    }
}